package study.cell_game.objects;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import study.cell_game.enums.BorderType;
import study.cell_game.enums.PlayerColor;
import study.cell_game.objects.tokens.Token;
import study.cell_game.objects.tokens.TokenFactory;

public class TokenDeck {
	private List<Token> tokens = new ArrayList<Token>();
	private static final int SIZE = 30;
	
	public TokenDeck(PlayerColor color){
		if (color != PlayerColor.RED)
		{
		Token[] tokens = new Token[]{ 
				TokenFactory.createRam1(BorderType.STRAIGHT_IN_OUT, 0, 0),
				TokenFactory.createProc1(BorderType.STRAIGHT_IN_OUT, 0, 0),
				
				
				TokenFactory.createProc1(BorderType.STRAIGHT_IN_OUT, 0, 0),
				TokenFactory.createProc1(BorderType.STRAIGHT_IN_OUT, 0, 0),
				TokenFactory.createProc1(BorderType.STRAIGHT_IN_OUT, 0, 0),
				TokenFactory.createProc1(BorderType.STRAIGHT_IN_OUT, 0, 0),
				
				//TokenFactory.createOvertake(0, 0),
				//TokenFactory.createOvertake(0, 0),
				TokenFactory.createRotate(0, 0),
				TokenFactory.createRotate(0, 0),
				
				
				TokenFactory.createProc2(BorderType.STRAIGHT_IN_OUT, 0, 0),
				TokenFactory.createProc2(BorderType.STRAIGHT_IN_OUT, 0, 0),
				TokenFactory.createProc2(BorderType.STRAIGHT_IN_OUT, 0, 0),
				
				TokenFactory.createRam1(BorderType.STRAIGHT_IN_OUT, 0, 0),
				TokenFactory.createRam1(BorderType.TRIANGLE_IN_TRIANGLE_OUT, 0, 0),
				TokenFactory.createRam1(BorderType.TRIANGLE_IN_OUT, 0, 0),
				TokenFactory.createRam1(BorderType.TRIANGLE_IN_OUT, 0, 0),
				
				//substytuty
				//TokenFactory.createProc2(BorderType.STRAIGHT_IN_OUT, 0, 0),
				//TokenFactory.createProc2(BorderType.STRAIGHT_IN_OUT, 0, 0),
				//TokenFactory.createProc2(BorderType.STRAIGHT_IN_OUT, 0, 0),
				
				//TokenFactory.createRam1(BorderType.STRAIGHT_IN_OUT, 0, 0),
				//TokenFactory.createRam1(BorderType.TRIANGLE_IN_TRIANGLE_OUT, 0, 0),
				//TokenFactory.createRam1(BorderType.TRIANGLE_IN_OUT, 0, 0),
				//TokenFactory.createRam1(BorderType.TRIANGLE_IN_OUT, 0, 0),
				TokenFactory.createRotate(0, 0),
				TokenFactory.createRotate(0, 0),
				TokenFactory.createRotate(0, 0),
				TokenFactory.createRotate(0, 0),
				TokenFactory.createRotate(0, 0),
				
				TokenFactory.createProc1(BorderType.TRIANGLE_IN_OUT, 0, 0),
				TokenFactory.createProc1(BorderType.TRIANGLE_IN_OUT, 0, 0),
				TokenFactory.createProc1(BorderType.TRIANGLE_IN_OUT, 0, 0),
				TokenFactory.createProc1(BorderType.TRIANGLE_IN_OUT, 0, 0),
				TokenFactory.createProc2(BorderType.TRIANGLE_IN_OUT, 0, 0),
				
				TokenFactory.createProc1(BorderType.TRIANGLE_IN_TRIANGLE_OUT, 0, 0),
				TokenFactory.createProc1(BorderType.TRIANGLE_IN_TRIANGLE_OUT, 0, 0),
				TokenFactory.createProc1(BorderType.TRIANGLE_IN_TRIANGLE_OUT, 0, 0),
				TokenFactory.createProc1(BorderType.TRIANGLE_IN_TRIANGLE_OUT, 0, 0),
				TokenFactory.createProc2(BorderType.TRIANGLE_IN_TRIANGLE_OUT, 0, 0)
				
		};
		this.tokens = new ArrayList<Token>(Arrays.asList(tokens));
		}
		else
		{
			Token[] tokens = new Token[]{ 
					TokenFactory.createRam1(BorderType.STRAIGHT_IN_OUT, 0, 0),
					TokenFactory.createProc1(BorderType.STRAIGHT_IN_OUT, 0, 0),
					
					
					TokenFactory.createProc1(BorderType.STRAIGHT_IN_OUT, 0, 0),
					TokenFactory.createProc1(BorderType.STRAIGHT_IN_OUT, 0, 0),
					TokenFactory.createProc1(BorderType.STRAIGHT_IN_OUT, 0, 0),
					TokenFactory.createProc1(BorderType.STRAIGHT_IN_OUT, 0, 0),
					
					TokenFactory.createProc2(BorderType.TRIANGLE_IN_TRIANGLE_OUT, 0, 0),
					TokenFactory.createProc2(BorderType.TRIANGLE_IN_TRIANGLE_OUT, 0, 0),
					TokenFactory.createProc2(BorderType.STRAIGHT_IN_OUT, 0, 0),
					TokenFactory.createProc2(BorderType.STRAIGHT_IN_OUT, 0, 0),
					TokenFactory.createProc2(BorderType.STRAIGHT_IN_OUT, 0, 0),
					
					TokenFactory.createRam1(BorderType.STRAIGHT_IN_OUT, 0, 0),
					TokenFactory.createRam1(BorderType.TRIANGLE_IN_TRIANGLE_OUT, 0, 0),
					TokenFactory.createRam1(BorderType.TRIANGLE_IN_OUT, 0, 0),
					TokenFactory.createRam1(BorderType.TRIANGLE_IN_OUT, 0, 0),
					
					TokenFactory.createProc1(BorderType.TRIANGLE_IN_TRIANGLE_OUT, 0, 0),
					TokenFactory.createProc1(BorderType.TRIANGLE_IN_TRIANGLE_OUT, 0, 0),
					TokenFactory.createProc1(BorderType.TRIANGLE_IN_TRIANGLE_OUT, 0, 0),
					TokenFactory.createProc1(BorderType.TRIANGLE_IN_TRIANGLE_OUT, 0, 0),
					TokenFactory.createProc2(BorderType.TRIANGLE_IN_TRIANGLE_OUT, 0, 0),
					
					TokenFactory.createProc1(BorderType.TRIANGLE_IN_OUT, 0, 0),
					TokenFactory.createProc1(BorderType.TRIANGLE_IN_OUT, 0, 0),
					TokenFactory.createProc1(BorderType.TRIANGLE_IN_OUT, 0, 0),
					TokenFactory.createProc1(BorderType.TRIANGLE_IN_OUT, 0, 0),
					TokenFactory.createProc2(BorderType.TRIANGLE_IN_OUT, 0, 0),
					
					TokenFactory.createProc1(BorderType.TRIANGLE_IN_TRIANGLE_OUT, 0, 0),
					TokenFactory.createProc1(BorderType.TRIANGLE_IN_TRIANGLE_OUT, 0, 0),
					TokenFactory.createProc1(BorderType.TRIANGLE_IN_TRIANGLE_OUT, 0, 0),
					TokenFactory.createProc1(BorderType.TRIANGLE_IN_TRIANGLE_OUT, 0, 0),
					TokenFactory.createProc2(BorderType.TRIANGLE_IN_TRIANGLE_OUT, 0, 0)
					
			};
			this.tokens = new ArrayList<Token>(Arrays.asList(tokens));
		}
		
	}
	
	
	public void shuffle(){
		Collections.shuffle(tokens);
	}
	
	public Token take(){
		if(!tokens.isEmpty()){
			return tokens.remove(0);
		}
		return null;
	}
	
}
